#include "ftcomboboxdialog.h"
#include "ftvboxlayout.h"
#include "ftlist.h"
#include "ftlabel.h"
#include "ftpushbutton.h"

FTComboBoxDialog::FTComboBoxDialog(const QStringList & l, int s) :
    RotatingDialog()
{
    selected = s;
    list = new FTList();
    list->appendStrings( l );
    list->selectIndex( s );
    connect( list, SIGNAL(indexSelected(int)),
             this, SLOT(selectedItem(int)) );

    cancelButton = new FTPushButton( tr("Cancel") );
    connect( cancelButton, SIGNAL(clicked()),
             this, SLOT(reject()));
}

int FTComboBoxDialog::userSelect()
{
    if ( exec() == QDialog::Accepted )
        return selected;
    return -1;
}

void FTComboBoxDialog::selectedItem(int i)
{
    selected = i;
    emit accept();
}

QLayout* FTComboBoxDialog::createVertical()
{
    FTVBoxLayout* grid = new FTVBoxLayout();
    grid->addWidget( list );
    grid->addWidget( cancelButton );
    return grid;
}
